package com.ljh.SimpleTradingSystem.mybatis.mapper;

import com.ljh.SimpleTradingSystem.mybatis.entity.Auction;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AuctionMapper {
    @Select("select * from auction where goodsId = #{goodsId}")
    List<Auction> selectByGoodsId(int goodsId);

    @Select("select * from auction where goodsId = #{goodsId} order by price desc limit 1")
    Auction getMaxPriceByGoodsId(int goodsId);

    @Insert("insert into auction(goodsId, userName, price, time)" +
            "values (#{goodsId}, #{userName}, #{price}, #{time})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Auction auction);
}
